#include "../include/stu.h"

void enter_sk(){
    system("clear");
    int exist = 0; //重复标志
    struct student *p1,*p2,*p3;
    printf("输入学生信息：\n");
    printf("退出：quit\n");
    printf("学号\t姓名\t课程数\t课程\t学分\n");
    while(1){
        p2 = (struct student *)malloc(sizeof(struct student));
        scanf("%s",p2->id);
        if(strcmp(p2->id,"quit") == 0)
            return ;
        scanf("%s %d",p2->name,&p2->num);
        for(int i=0; i<p2->num; i++){
            scanf("%d",&p2->class[i]);
        }
        scanf("%d",&p2->credit);
        if(head1 == NULL){
            head1 = p2;
            printf("success1\n");
        }else{
            p1 = head1;
            p3 = p1;
            while(p1 != NULL){
                if(strcmp(p1->id,p2->id)==0){
                    printf("该学号存在，重新输入\n");
                    exist = 1;
                    break;
                }
                p3 = p1;
                p1 = p1->next;
            }
            if(exist)
                continue;
            p3->next = p2;
            p2->next = NULL;
            printf("success2\n");
        }
    }
}
